import { Next, ParameterizedContext } from 'koa'

/**
 * cors跨域处理 中间件
 */
export const cors = async (ctx: ParameterizedContext, next: Next) => {
  ctx.set('Access-Control-Allow-Origin', '*')
  ctx.set(
    'Access-Control-Allow-Headers',
    'Content-Type,Content-Length,token,Accept,X-Requested-With',
  )
  ctx.set('Access-Control-Allow-Methods', 'PUT,POST,GET,DELETE,OPTIONS')
  await next()
}
